# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=flit
pkgbase=mingw-w64-python-${_realname}-core
pkgname=(${MINGW_PACKAGE_PREFIX}-python-$_realname-core)
pkgver=3.8.0
pkgrel=1
pkgdesc='Simplified packaging of Python modules (core backend) (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/takluyver/flit'
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
source=("${_realname}-$pkgver.tar.gz"::"$url/archive/$pkgver.tar.gz")
sha256sums=('ecb47fa7226befe109e1c4999e0597a4446912a3917833fb23211545632728da')

prepare() {
  cd "${_realname}-${pkgver}"
}

build() {
  cd "${_realname}-${pkgver}/flit_core"

  PYTHONPATH=flit_core python -m flit_core.wheel
}

package() {
  cd "${_realname}-${pkgver}/flit_core"

  _pythonpath=`python -c "import sysconfig; print(sysconfig.get_path('platlib'))"`
  _site_packages="${pkgdir}$(cygpath ${_pythonpath})"
  mkdir -p "$_site_packages"
  python bootstrap_install.py -i"${_site_packages}" dist/flit_core-*.whl

  MSYS2_ARG_CONV_EXCL="-p" python -m compileall \
    -o 0 -o 1 -q -s"${pkgdir}" -p"/" "${pkgdir}${MINGW_PREFIX}/lib/python"*

  install -Dm 644 ../LICENSE "$pkgdir${MINGW_PREFIX}"/share/licenses/${_realname}-core/LICENSE
}
